home *** CD-ROM | disk | FTP | other *** search
-
- {* Hardcore Pascal Object Coding done by Zulu & Grey of Rebels *}
-
- PROGRAM definition_der_objekte_und_organisation;
-
- USES graph,crt;
-
- TYPE punkt = OBJECT
- x,
- y : REAL;
-
- CONSTRUCTOR init(xwert,ywert : REAL);
- procedure out(VAR xwert,ywert : REAL);
- procedure zeigen; virtual;
- procedure loeschen; virtual;
- procedure addition(dx,dy : REAL); virtual;
- procedure multiply(mx,my : REAL); virtual;
- procedure spiegelnY(cy : real); virtual;
- procedure spiegelnX(cx : real); virtual;
- procedure verschieben(dx,dy,sx1,sy1,cx1,cy1 : real); virtual;
- procedure skalieren(bx,by,vx,vy: real);virtual;
- END;
-
- linie = OBJECT(punkt)
- x1,
- y1 : REAL;
-
- CONSTRUCTOR init(xwert,ywert,x1wert,y1wert : REAL);
- procedure out(VAR xwert,ywert,x1wert,y1wert : REAL);
- procedure zeigen; virtual;
- procedure addition(dx,dy : REAL); virtual;
- procedure multiply(mx,my : REAL); virtual;
-
- {Prozedur VERSCHIEBEN wurde geerbt!}
- END;
-
- kreis = OBJECT(punkt)
- radius : REAL;
-
- CONSTRUCTOR init(xwert,ywert,rad : REAL);
- procedure out(VAR xwert,ywert,rad : REAL);
- procedure zeigen; virtual;
-
- {Prozeduren ADDITION und VERSCHIEBEN von "punkt" geerbt!}
- END;
-
- rechteck = OBJECT(linie)
- procedure zeigen; virtual;
-
- {Restprozeduren von "linie" geerbt!}
- END;
-
- {------------------------------Objekt Punkt----------------------------------}
-
- CONSTRUCTOR punkt.init(xwert,ywert : REAL);
-
- BEGIN
- x := xwert;
- y := ywert;
- END;
-
- PROCEDURE punkt.out(VAR xwert,ywert : REAL);
-
- BEGIN
- xwert := x;
- ywert := y;
- END;
-
- PROCEDURE punkt.zeigen;
-
- BEGIN
- putpixel(round(x),round(y),getcolor);
- {Pixel an der Stelle (x,y) mit akt.Zeichenfarbe}
- END;
-
- PROCEDURE punkt.loeschen;
-
- VAR altfarbe : WORD;
-
- BEGIN
- altfarbe := getcolor;
- setcolor(getbkcolor);
- zeigen;
- setcolor(altfarbe);
- END;
-
- PROCEDURE punkt.addition(dx,dy : REAL);
-
- BEGIN
- x := x + dx;
- y := y + dy;
- END;
-
- PROCEDURE punkt.verschieben(dx,dy,sx1,sy1,cx1,cy1 : real);
-
- BEGIN
-
- addition(0,0);
- { spiegelnx(sx1,sy1,cx1,cy1); }
- zeigen;
- END;
-
- PROCEDURE punkt.multiply(mx,my : real);
-
- BEGIN
- x:=x * mx;
- y:=y * my;
- END;
-
- procedure punkt.skalieren(bx,by,vx,vy: real);
-
- BEGIN
- addition(-bx,-by);
- multiply(vx,vy);
- addition(bx,by);
- END;
-
- PROCEDURE punkt.spiegelnY(cy : real);
-
- BEGIN
- addition((-1)*cy,0);
- multiply(-1,1);
- addition(cy,0);
-
- END;
-
- PROCEDURE punkt.spiegelnX(cx : real);
-
- BEGIN
- addition(0,(-1)*cx);
- multiply(1,-1);
- addition(0,cx);
-
- END;
-
-
- {-------------------------------Objekt Linie---------------------------------}
-
- CONSTRUCTOR linie.init(xwert,ywert,x1wert,y1wert : REAL);
-
- BEGIN
- x := xwert;
- y := ywert;
- x1 := x1wert;
- y1 := y1wert;
- END;
-
- PROCEDURE linie.out(VAR xwert,ywert,x1wert,y1wert : REAL);
-
- BEGIN
- xwert := x;
- ywert := y;
- x1wert := x1;
- y1wert := y1;
- END;
-
- PROCEDURE linie.zeigen;
-
- BEGIN
- line(round(x),round(y),round(x1),round(y1));
- END;
-
- PROCEDURE linie.addition;
-
- BEGIN
- x := x + dx;
- y := y + dy;
- x1 := x1 + dx;
- y1 := y1 + dy;
- END;
-
- PROCEDURE linie.multiply(mx,my: REAL);
-
- BEGIN
-
- x:=x * mx;
- y:=y * my;
- x1:=x1 * mx;
- y1:=y1 * my;
-
- END;
-
-
- {------------------------------Objekt Kreis----------------------------------}
-
- CONSTRUCTOR kreis.init(xwert,ywert,rad : REAL);
-
- BEGIN
- x := xwert;
- y := ywert;
- radius := rad;
- END;
-
- PROCEDURE kreis.out(VAR xwert,ywert,rad : REAL);
-
- BEGIN
- xwert := x;
- ywert := y;
- rad := radius;
- END;
-
- PROCEDURE kreis.zeigen;
-
- BEGIN
- circle(round(x),round(y),round(radius));
- END;
-
- {-------------------------------Objekt Rechteck 1----------------------------}
-
- PROCEDURE rechteck.zeigen;
-
- BEGIN
- rectangle(round(x),round(y),round(x1),round(y1));
- END;
-
- {--------------------------------Hauptprogramm-------------------------------}
-
- { Ab hier stehen alle Verschiebungsprozeduren fr die vordefinierten Objekte }
- { zur Verfgung! }
-
- VAR
- graphdriver,
- graphmode,
- dx,
- realdx,
- realdy,
- zoom,
- circx,
- circy,
- sx1,sy1,cx1,cy1,
- bx,by,
- dy : INTEGER;
- vx,vy,vx1,vy1 : real;
- ch,ch1 : CHAR;
- opunkt : punkt;
- olinie : linie;
- orechteck : rechteck;
- nrechteck : rechteck;
- okreis : kreis;
- ncircle : kreis;
-
- BEGIN
-
- { Anzeigeobjekte vordefinieren }
- bx:=320;
- by:=240;
- vx:=1.01;
- vy:=1.01;
- vx1:=0.99;
- vy1:=0.99;
- cx1:=240;
- cy1:=320;
- sx1:=1;
- sy1:=-1;
- okreis.init(320,240,50);
- orechteck.init(220,180,420,300);
- opunkt.init(320,240);
- olinie.init(230,190,260,190);
-
- { Eingeben der Dx und Dy Werte }
-
- write('Bitte geben Sie den Y-Skalierwert ein (>1): ');readln(vy);
- write('Bitte geben Sie den X-Skalierwert ein (>1): ');readln(vx);
- write('Bitte geben Sie den Y-Skalierwert ein (0<>1): ');readln(vy1);
- write('Bitte geben Sie den X-Skalierwert ein (0<>1): ');readln(vx1);
-
- { Grafikmodus einschalten }
- graphdriver := detect;
- initgraph(graphdriver,graphmode,'c:\tp\bgi');
-
- { Objekte darstellen }
- { okreis.zeigen;
- orechteck.zeigen;
- olinie.zeigen;
- opunkt.zeigen;
- nrechteck.zeigen;
- ncircle.zeigen; }
-
- { Arbeitsschleife }
- repeat
- cleardevice;
- okreis.zeigen;
- orechteck.zeigen;
- olinie.zeigen;
- opunkt.zeigen;
- ch := readkey;
- case ch of
- 'c' : begin
- settextstyle(1,0,1);
- outtextxy(0,10,'Bitte geben Sie den Y-Skalierwert ein (>1): ');gotoxy(60,2);readln(vy);
- outtextxy(0,30,'Bitte geben Sie den X-Skalierwert ein (>1): ');gotoxy(60,3);readln(vx);
- outtextxy(0,50,'Bitte geben Sie den Y-Skalierwert ein (0<>1): ');gotoxy(60,4);readln(vy1);
- outtextxy(0,70,'Bitte geben Sie den X-Skalierwert ein (0<>1): ');gotoxy(60,5);readln(vx1);
- cleardevice;
- end;
-
- 'z' : begin
- opunkt.skalieren(bx,by,vx,vy);
- okreis.skalieren(bx,by,vx,vy);
- orechteck.skalieren(bx,by,vx,vy);
- olinie.skalieren(bx,by,vx,vy);
- end;
- 'Z' : begin
- opunkt.skalieren(bx,by,vx1,vy1);
- okreis.skalieren(bx,by,vx1,vy1);
- orechteck.skalieren(bx,by,vx1,vy1);
- olinie.skalieren(bx,by,vx1,vy1);
- end;
-
- 'x' : begin
- olinie.spiegelnX(cx1);
- opunkt.spiegelnX(cx1);
- okreis.spiegelnX(cx1);
- orechteck.spiegelnX(cx1);
- end;
- 'y' : begin
- olinie.spiegelnY(cy1);
- opunkt.spiegelnY(cy1);
- okreis.spiegelnY(cy1);
- orechteck.spiegelnY(cy1);
- end;
- else write (#7);
-
- END;
-
-
- UNTIL ch=#13; { abbrechen, wenn RETURN gedrckt wurde }
- closegraph; { zurckkehren zum Text-Modus }
- END.
-